<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends BaseController {
	
    public function index(){
            $admin=M();
            $sdk_admin=$admin->table('ymn_sdk_admin')->select();
            
            //$app_admin['0']['username']= 1;
           // var_dump($app_admin);

           
            $this->assign('sdk_admin',$sdk_admin);
            
            
            $this->display();
        
        
    }
    public function add_sdk(){
        $admin=M();
        $info['name']=I('post.name');
        $info['introduction']=I('post.intro');
        $info['state']=I('post.state');
        $info['create_time']=date('Y-m-d H:i:s');
        if(!$info['name']){
            echo "名称不能为空";
        }else{
            $result=$admin->table('ymn_sdk_admin')->add($info);
            if($result){
                echo "新增成功";
            }else{
                echo "新增失败";
            }
        }
        

    }

    public function edit(){
       
        $id=I('post.id');
        
        $info['name']=I('post.name');
        $info['introduction']=I('post.intro');
        $info['state']=I('post.state');
        $info['create_time']=date('Y-m-d H:i:s');
        
        $admin=M();
        $result=$admin->table('ymn_sdk_admin')->where("id='".$id."'")->save($info);
        //$result=$admin->table('ymn_sdk_admin')->save($info);
        if($result){
            echo "保存成功";
        }else{
            echo "保存失败";
        }
    }
    
    public function add_version(){
        
        if($_GET['sssid']){
            $s=$_GET['sssid'];

            $this->assign('s',$s);
        }
                
        $admin=M();
        $sdk_add=$admin->table('ymn_sdk_add')->select();
        $this->assign('sdk_add',$sdk_add);
        $this->display('add_version');
    
    }
   
    
    public function release(){
        $id=I('post.id');
        $admin=M();
        $adm=$admin->table('ymn_sdk_admin')->where("id='".$id."'")->find(); 
        $version_id=$adm['version_id'];
        
        //发布
        $add=$admin->table('ymn_sdk_add')->where("id='".$version_id."'")->find();
        $adm_time['release_time']=date('Y-m-d H:i:s');
        $result=$admin->table('ymn_sdk_add')->where("id='".$version_id."'")->save($adm_time);
        $adm_time['release_state']=1;
        $result=$admin->table('ymn_sdk_admin')->where("id='".$id."'")->save($adm_time);

    
        echo "发布成功";
        
    }

     
    
}
   
